﻿@using Gx.Model.ViewModel;
@model LKTransferDto
@{
    ViewBag.Title = "编辑商品转卡单";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}
<script src="~/Js/Global.js?v=20240706"></script>
<script type="text/javascript">
    $(function () {
        InitChargingUnitCombobox();
        InitColdAlgorithmCombobox();
        InitCustomerById(InCustomerId, incustomerselecttoolbar, selectInCustomer);
        InitCustomerById(OutCustomerId, outcustomerselecttoolbar, selectOutCustomer);
        $('#sbIsByTon').switchbutton({ checked: @Html.Raw(Model.Transfer.IsByTon ? "true" : "false") });
        $('#ChargingUnit').combobox('setValue', @Model.Transfer.ChargingUnit);
        $('#ColdAlgorithm').combobox('setValue', @Model.Transfer.ColdAlgorithm);
        $('#InCustomerId').combogrid('setValue', { Id: '@Model.Transfer.InCustomerId', CustomerName: '@Model.Transfer.InCustomerNo' });
        $('#OutCustomerId').combogrid('setValue', { Id: '@Model.Transfer.OutCustomerId', CustomerName: '@Model.Transfer.OutCustomerNo' });
        $('#CurrentDayColdCost1').checkbox({ checked: @Html.Raw(Model.Transfer.CurrentDayColdCost=="1" || Model.Transfer.CurrentDayColdCost == "3" ? "true" : "false")});
        $('#CurrentDayColdCost2').checkbox({ checked: @Html.Raw(Model.Transfer.CurrentDayColdCost=="2" || Model.Transfer.CurrentDayColdCost == "3" ? "true" : "false")});
    });

    function selectInCustomer(row) {
        $('#InCustomerName').textbox('setValue', row.CustomerName);
        $('#ContractNo').combogrid({
            url: "/LKWarehouseContract/GetContractByCustomerId?customerId=" + row.Id,
            method: 'post',
            mode: 'remote',
            panelWidth: 500,
            idField: 'ContractNo',
            textField: 'ContractNo',
            onSelect: function () {
                var g = $('#ContractNo').combogrid('grid');
                var row = g.datagrid('getSelected');
                loadContractInfo(row);
            },
            columns: [[
                { field: 'ContractType', title: 'ContractType', hidden: true },
                { field: 'ContractNo', title: '合同', width: 120, align: 'right' },
                { field: 'ContractTypeName', title: '合同类型', width: 150, align: 'right' },
                { field: 'ChargingUnit', title: 'ChargingUnit', hidden: true },
                { field: 'ChargingUnitName', title: 'ChargingUnitName', hidden: true },
                { field: 'ColdAlgorithm', title: 'ColdAlgorithm', hidden: true },
                { field: 'ColdAlgorithmName', title: 'ColdAlgorithmName', hidden: true },
                { field: 'Cycle', title: 'Cycle', hidden: true },
                { field: 'ColdUnitPrice', title: 'ColdUnitPrice', hidden: true },
            ]],
            onLoadSuccess: function (data) {
                //var dataCount = data.total; // 获取加载成功后的数据条数
                if (data.total == 1) {
                    var row = data.rows[0];
                    loadContractInfo(row);
                }
            }
        });
    }
    function selectOutCustomer(row) {
        $('#OutCustomerName').textbox('setValue', row.CustomerName);
    }
    function loadContractInfo(row) {
        $('#ContractNo').combogrid('setValue', row.ContractNo);
        //$('#ContractId').val(row.ContractId);
        $('#RentalWarehouseTypeName').textbox('setValue', row.ContractTypeName);
        $('#RentalWarehouseType').val(row.ContractType)
        if (row.ContractType == 1) {
            $('#ChargingUnitName').textbox('enable');
            $('#ColdAlgorithmName').textbox('enable');
            $('#Cycle').numberbox('enable');
            $('#ColdUnitPrice').numberbox('enable');

            $('#ChargingUnitName').textbox('setValue', row.ChargingUnitName);
            $('#ChargingUnit').val(row.ChargingUnit);

            $('#ColdAlgorithmName').textbox('setValue', row.ColdAlgorithmName);
            $('#ColdAlgorithm').val(row.ColdAlgorithm);

            $('#Cycle').numberbox('setValue', row.Cycle);
            $('#ColdUnitPrice').numberbox('setValue', row.ColdUnitPrice);
        } else {
            $('#ChargingUnitName').textbox('disable');
            $('#ColdAlgorithmName').textbox('disable');
            $('#Cycle').numberbox('disable');
            $('#ColdUnitPrice').numberbox('disable');
        }
    }

    function addDom() {
        var customerId = $("#OutCustomerId").combobox('getValue');
        if (customerId == "") {
            Helper.Show("请选择客户");
            return;
        }
        $('#dlg').dialog('open').dialog('setTitle', '引导式转卡');
        $('#dg').datagrid('load', {
            CustomerId: customerId
        });
        initDom();
    }

    function delDom(domId) {
        $("#" + domId).remove();
        removecalculateWeight();
    }

    function addDom2() {
        var domId2 = $("#CostDomNum").val();
        $.post("/GoodsOrder/_AddLKWarehouseEntryCost", { domId: domId2 }, function (html) {
            $.messager.progress('close');
            $("#costgird").append(html);
            $.parser.parse($("#CostTr" + domId2));
            InitCostTypesCombogrid2(domId2, initCostType);
            InitChargingUnitCombobox(domId2);
            $("#CostDomNum").val(Number(domId2) + 1);

            initDom();
        });
    }

    function delDom2(id) {
        $("#CostTr" + id).remove();

        //domId2 = Number(domId2) - 1;
        removecalculateAmount();
    }

    function addDom3() {
        var domId3 = $("#OCostDomNum").val();
        $.post("/GoodsOrder/_AddLKTransferOutCost", { domId: domId3 }, function (html) {
            $.messager.progress('close');
            $("#outcostgird").append(html);
            $.parser.parse($("#OutCostTr" + domId3));
            var OCostType = "OCostType" + domId3;
            InitCostTypesCombogridById(OCostType, domId3, initOutCostType);
            InitChargingUnitComboboxById("OChargingUnit" + domId3);
            $("#OCostDomNum").val(Number(domId3) + 1);

            initDom();
        });
    }

    function delDom3(id) {
        $("#OutCostTr" + id).remove();

        //domId2 = Number(domId2) - 1;
        removecalculateAmount();
    }

    var outcostdom = new Array();
    var costdom = new Array();
    var detaildom = new Array();

    function initDom() {
        costdom.length = 0;
        detaildom.length = 0;
        outcostdom.length = 0;
        $("input[type='hidden'][id^='OCostDomId']").each(function () {
            var d = $(this).val();
            if ($.inArray(d, outcostdom) === -1) {
                outcostdom.push(d);
            }
        });
        $("input[type='hidden'][id^='CostDomId']").each(function () {
            var d = $(this).val();
            if ($.inArray(d, costdom) === -1) {
                costdom.push(d);
            }
        });
        $("input[type='hidden'][id^='DetailDomId']").each(function () {
            var d = $(this).val();
            if ($.inArray(d, detaildom) === -1) {
                detaildom.push(d);
            }
        });

    }


    function selectEntryDetail() {
        var detail = $('#dg').datagrid('getSelected');
        if (detail == null) {
            Helper.Show("请选择商品");
            return;
        }

        var domId = $("#DomNum").val();
        $.post("/GoodsOrder/_AddLKTransferDetail", { domId: domId }, function (html) {
            $.messager.progress('close');
            $("#detailgird").append(html);
            $.parser.parse($("#" + domId));
            InitInWareHouse(domId);
            initTransferDetail(domId, detail);
            $("#DomNum").val(Number(domId) + 1);
        });


        $('#dlg').dialog('close');
    }
    function initTransferDetail(id, detail) {
        $("#GoodsNo" + id).textbox('setValue', detail.GoodsNo);
        $("#NewGoodsNo" + id).textbox('setValue', detail.GoodsNo + "A");
        $("#GoodsId" + id).val(detail.GoodsId);
        $("#GoodsName" + id).textbox('setValue', detail.GoodsName);
        $("#GoodsSpecId" + id).val(detail.GoodsSpecId);
        $("#GoodsSpecName" + id).textbox('setValue', detail.GoodsSpecName);
        $("#Weight" + id).numberbox('setValue', detail.Weight);
        /*$("#TransferNumber" + id).numberbox('setValue', detail.Number);*/
        /*$("#PlateNumber" + id).numberbox('setValue', detail.PlateNumber);*/
        $("#Area" + id).numberbox('setValue', detail.Area);
        $("#InventoryTonWeight" + id).numberbox('setValue', detail.TonWeight);
        $("#InventoryNumber" + id).numberbox('setValue', detail.Number);
        $("#OutHouse" + id).val(detail.WareHouseId);
        $("#OutHouseName" + id).textbox('setValue', detail.WareHouseName);
    }

    function InitInWareHouse(domId) {
        if (domId == undefined) {
            domId = "";
        }
        $('#InHouse' + domId).combotree({
            url: "/BasicManage/GetHouseComboxTree",
            editable: false,
            valueField: 'Id',
            textField: 'WareHouseName',
            onSelect: function (rec) {
            }
        })
    }

    //计算总重量
    function calculateWeight() {
        initDom();

        var totalton = 0;
        var total = 0;
        detaildom.forEach(function (value, index) {
            var i = value;
            var numbers = $("#TransferNumber" + i).numberbox('getValue') * 1;
            var weights = $("#TonWeight" + i).numberbox('getValue') * 1;

            //var tonweight = (numbers * weights.toFixed(2)) / 1000;
            totalton += weights;//tonweight;
            total += numbers;
        });
        $("#TotalTon").numberbox('setValue', totalton);
        $("#Total").numberbox('setValue', total);
    }

    function removecalculateWeight() {
        initDom();
        var totalton = 0;
        var total = 0;
        detaildom.forEach(function (value, index) {
            var i = value;
            var numbers = $("#TransferNumber" + i).numberbox('getValue') * 1;
            var weights = $("#TonWeight" + i).numberbox('getValue') * 1;

            //var tonweight = (numbers * weights.toFixed(2)) / 1000;
            totalton += weights;//tonweight;
            total += numbers;
        });
        $("#TotalTon").numberbox('setValue', totalton);
        $("#Total").numberbox('setValue', total);
    }


    //计算金额
    function calculateAmount() {
        initDom();
        var triggerControl = this;
        var value = $(triggerControl).numberbox('getValue');

        //获取triggerControl的id的最后一个字符
        var id = $(triggerControl).attr("id");
        var lastChar = id.substr(id.length - 1, 1);
        var number = $("#CNumber" + lastChar).numberbox('getValue') * 1;
        var unitprice = $("#UnitPrice" + lastChar).numberbox('getValue') * 1;
        var amount = (number * unitprice).toFixed(2);
        $("#Amount" + lastChar).numberbox('setValue', amount);

        var totalAmount = 0.00;
        costdom.forEach(function (value, index) {
            var i = value;
            var numbers = $("#CNumber" + i).numberbox('getValue') * 1;
            var unitprices = $("#UnitPrice" + i).numberbox('getValue') * 1;

            var tonam = (numbers * unitprices).toFixed(2) * 1;
            totalAmount += tonam;
        });
        $("#InAmount").numberbox('setValue', totalAmount);
    }

    function removecalculateAmount() {
        initDom();
        var totalAmount = 0.00;
        costdom.forEach(function (value, index) {
            var i = value;
            var numbers = $("#CNumber" + i).numberbox('getValue') * 1;
            var unitprices = $("#UnitPrice" + i).numberbox('getValue') * 1;

            var tonam = (numbers * unitprices).toFixed(2) * 1;
            totalAmount += tonam;
        });
        $("#InAmount").numberbox('setValue', totalAmount);
    }


    //计算转出金额
    function calculateAmount2() {
        initDom();
        var triggerControl = this;
        var value = $(triggerControl).numberbox('getValue');

        //获取triggerControl的id的最后一个字符
        var id = $(triggerControl).attr("id");
        var lastChar = id.substr(id.length - 1, 1);
        var number = $("#ONumber" + lastChar).numberbox('getValue') * 1;
        var unitprice = $("#OUnitPrice" + lastChar).numberbox('getValue') * 1;
        var amount = (number * unitprice).toFixed(2);
        $("#OAmount" + lastChar).numberbox('setValue', amount);

        var totalAmount = 0.00;
        outcostdom.forEach(function (value, index) {
            var i = value;
            var numbers = $("#ONumber" + i).numberbox('getValue') * 1;
            var unitprices = $("#OUnitPrice" + i).numberbox('getValue') * 1;

            var tonam = (numbers * unitprices).toFixed(2) * 1;
            totalAmount += tonam;
        });
        $("#OutAmout").numberbox('setValue', totalAmount);
    }

    function removecalculateAmount2() {
        initDom();
        var totalAmount = 0.00;
        outcostdom.forEach(function (value, index) {
            var i = value;
            var numbers = $("#ONumber" + i).numberbox('getValue') * 1;
            var unitprices = $("#OUnitPrice" + i).numberbox('getValue') * 1;

            var tonam = (numbers * unitprices).toFixed(2) * 1;
            totalAmount += tonam;
        });
        $("#OutAmout").numberbox('setValue', totalAmount);
    }

    function initCostType(row) {
        var id = row.did;
        $("#CostTypeId" + id).val(row.data.Id);//combobox('setValue', rowData.Id);
        $("#CostType" + id).combobox('setValue', row.data.CostTypeName);
        $("#ChargingUnit" + id).combobox('setValue', row.data.Unit);
        $("#UnitPrice" + id).numberbox('setValue', row.data.UnitPrice);
    }

    function initOutCostType(row) {
        var id = row.did;
        $("#OCostTypeId" + id).val(row.data.Id);//combobox('setValue', rowData.Id);
        $("#OCostType" + id).combobox('setValue', row.data.CostTypeName);
        $("#OChargingUnit" + id).combobox('setValue', row.data.Unit);
        $("#OUnitPrice" + id).numberbox('setValue', row.data.UnitPrice);
    }


    function querycustomer1() {
        $("#InCustomerId").combogrid("grid").datagrid("reload", { "Customer": $("#SelectCustomerText1").val() });
    }
    function querycustomer2() {
        $("#OutCustomerId").combogrid("grid").datagrid("reload", { "Customer": $("#SelectCustomerText2").val() });
    }


    function editLKTransfer() {
        var validate = $("#fm").form("validate")
        if (!validate) {
            return;
        }

        var CurrentDayColdCost = "";
        if ($('input[name="CurrentDayColdCost1"]').prop('checked') && $('input[name="CurrentDayColdCost2"]').prop('checked')) {
            CurrentDayColdCost = "3";
        } else if ($('input[name="CurrentDayColdCost1"]').prop('checked')) {
            CurrentDayColdCost = "1";
        } else if ($('input[name="CurrentDayColdCost2"]').prop('checked')) {
            CurrentDayColdCost = "2";
        }
        var data = {
            "Id": $("#Id").val(),
            "TransferNo": $("#TransferNo").textbox('getValue'),
            "TransferTime": $("#TransferTime").datebox('getValue'),
            "InCustomerId": $("#InCustomerId").combobox('getValue'),
            "InCustomerNo": $("#InCustomerId").combobox('getText'),
            "InCustomerName": $("#InCustomerName").textbox('getValue'),
            "OutCustomerId": $("#OutCustomerId").combobox('getValue'),
            "OutCustomerNo": $("#OutCustomerId").combobox('getText'),
            "OutCustomerName": $("#OutCustomerName").textbox('getValue'),

            "ContractNo": $("#ContractNo").textbox('getValue'),
            "RentalWarehouseType": $("#RentalWarehouseType").val(),
            "ColdAlgorithm": $("#ColdAlgorithm").val(),
            "ChargingUnit": $("#ChargingUnit").val(),
            "IsByTon": $('#sbIsByTon').switchbutton('options').checked,
            "Cycle": $("#Cycle").numberbox('getValue'),
            "ColdUnitPrice": $("#ColdUnitPrice").numberbox('getValue'),
            "Tonnage": $("#Tonnage").numberbox('getValue'),
            "TotalTon": $("#TotalTon").numberbox('getValue'),
            "Total": $("#Total").numberbox('getValue'),
            "InAmount": $("#InAmount").numberbox('getValue'),
            "OutAmout": $("#OutAmout").numberbox('getValue'),
            "CurrentDayColdCost": CurrentDayColdCost,
            "Remark": $("#Remark").val(),
        };

        initDom();
        var detailList = new Array();
        detaildom.forEach(function (value, index) {
            var i = value;
            var Id = $("#DetailId" + i).val();
            var TransferId = $("#TransferId" + i).val();
            var GoodsNo = $("#GoodsNo" + i).textbox('getValue');
            var NewGoodsNo = $("#NewGoodsNo" + i).textbox('getValue');
            var GoodsId = $("#GoodsId" + i).val();
            var GoodsSpecId = $("#GoodsSpecId" + i).val();
            var GoodsName = $("#GoodsName" + i).textbox('getValue');
            var GoodsSpecName = $("#GoodsSpecName" + i).textbox('getValue');
            var Weight = $("#Weight" + i).numberbox('getValue');
            var TransferNumber = $("#TransferNumber" + i).numberbox('getValue');

            var Area = $("#Area" + i).numberbox('getValue');
            var PlatePosition = $("#PlatePosition" + i).numberbox('getValue');
            var TonWeight = $("#TonWeight" + i).numberbox('getValue');
            var InventoryNumber = $("#InventoryNumber" + i).numberbox('getValue');

            var InventoryArea = $("#InventoryArea" + i).numberbox('getValue');
            var InventoryTonWeight = $("#InventoryTonWeight" + i).numberbox('getValue');

            var OutHouse = $("#OutHouse" + i).val();
            var OutHouseName = $("#OutHouseName" + i).textbox('getValue');



            var InHouse = $("#InHouse" + i).combobox('getValue');
            var InHouseName = $("#InHouse" + i).combobox('getText');

            var detail = {
                "Id": Id,
                "TransferId": TransferId,
                "GoodsNo": GoodsNo,
                "NewGoodsNo": NewGoodsNo,
                "GoodsId": GoodsId,
                "GoodsName": GoodsName,
                "GoodsSpecId": GoodsSpecId,
                "GoodsSpecName": GoodsSpecName,
                "Weight": Weight,
                "TransferNumber": TransferNumber,
                "Area": Area,
                "PlatePosition": PlatePosition,
                "TonWeight": TonWeight,
                "InventoryNumber": InventoryNumber,
                "InventoryArea": InventoryArea,
                "InventoryTonWeight": InventoryTonWeight,
                "OutHouse": OutHouse,
                "OutHouseName": OutHouseName,
                "InHouse": InHouse,
                "InHouseName": InHouseName,
            };
            detailList.push(detail);
        });

        var costList = new Array();
        costdom.forEach(function (value, index) {
            var i = value;
            var Id = $("#CostsId" + i).val();
            var TransferId = $("#ITransferId" + i).val();
            var CostId = $("#CostType" + i).combobox('getValue');
            var UnitPrice = $("#UnitPrice" + i).numberbox('getValue');
            var Unit = $("#ChargingUnit" + i).numberbox('getValue');
            var UnitName = $("#ChargingUnit" + i).combobox('getText');
            var number = $("#CNumber" + i).numberbox('getValue');
            var Amount = $("#Amount" + i).numberbox('getValue');

            var cost = {
                "Id": Id,
                "TransferId": TransferId,
                "CostId": CostId,
                "UnitPrice": UnitPrice,
                "Unit": Unit,
                "UnitName": UnitName,
                "Number": number,
                "Amount": Amount,
                "TransferType": 1
            };
            costList.push(cost);
        });
        outcostdom.forEach(function (value, index) {
            var i = value;
            var Id = $("#OCostsId" + i).val();
            var TransferId = $("#OTransferId" + i).val();
            var CostId = $("#OCostType" + i).combobox('getValue');
            var UnitPrice = $("#OUnitPrice" + i).numberbox('getValue');
            var Unit = $("#OChargingUnit" + i).numberbox('getValue');
            var UnitName = $("#OChargingUnit" + i).combobox('getText');
            var number = $("#ONumber" + i).numberbox('getValue');
            var Amount = $("#OAmount" + i).numberbox('getValue');

            var cost = {
                "Id": Id,
                "TransferId": TransferId,
                "CostId": CostId,
                "UnitPrice": UnitPrice,
                "Unit": Unit,
                "UnitName": UnitName,
                "Number": number,
                "Amount": Amount,
                "TransferType": 2
            };
            costList.push(cost);
        });

        var d = JSON.stringify({ Transfer: data, Costs: costList, Details: detailList, AttachmentId: $("#hidFileId").val() });
        $.messager.progress({
            title: '请稍后',
            msg: '数据保存中...',
        });
        window.setTimeout(function () {
            $.ajax({
                url: '/GoodsOrder/EditLKTransfer',
                type: "post",
                data: d,
                contentType: 'application/json; charset=utf-8',
                success: function (json) {
                    $.messager.progress('close');
                    Helper.Show(json.Msg);
                    if (json.Success) {
                        setTimeout(function () { window.location.href = "/GoodsOrder/LKTransferList"; }, 2000);
                    }
                }
            });
        }, 2000);
    }

</script>
<link href="~/Content/css/custome.css" rel="stylesheet" />
<div title="编辑商品转卡单" style="width:auto; height:auto; padding-left:5px; font-size:14px;  ">
    <div class="ftitle">
        @*<a href="javascript:" class="easyui-linkbutton" iconCls="icon-ok" style="height:32px" onclick="editLKTransfer()">保存</a>*@
        <a href="/GoodsOrder/LKTransferList" class="easyui-linkbutton" iconCls="icon-back" style="height:32px">返回</a>
    </div>
    <form id="fm" method="post" novalidate>
        <input type="hidden" id="Id" value="@Model.Transfer.Id" />
        <div class="ftitle">基础信息</div>
        <div class="fitem1">
            <label>
                转卡单编号:
            </label>
            <input class="easyui-textbox" id="TransferNo" name="TransferNo" value="@Model.Transfer.TransferNo" style="width: 173px; height: 30px;" readonly="readonly">
            <label>
                转卡时间:
            </label>
            <input id="TransferTime" name="TransferTime" value="@Model.Transfer.TransferTime.ToString("yyyy-MM-dd")" class="easyui-datebox" style="width: 173px; height: 30px;" />
        </div>
        <div class="fitem1">
            <label>
                转入客户:
            </label>
            <select class="easyui-combobox" id="InCustomerId" value="@Model.Transfer.InCustomerId" style="width: 173px; height: 30px;" data-options="editable: false,prompt:'转入客户;'"></select>
            <label>
                转入客户名称:
            </label>
            <input class="easyui-textbox" id="InCustomerName" name="InCustomerName" value="@Model.Transfer.InCustomerName" style="width: 173px; height: 30px;" readonly="readonly">
            <label>
                转出客户:
            </label>
            <select class="easyui-combobox" id="OutCustomerId" value="@Model.Transfer.OutCustomerId" style="width: 173px; height: 30px;" data-options="editable: false,prompt:'转出客户;'"></select>
            <label>
                转出客户名称:
            </label>
            <input class="easyui-textbox" id="OutCustomerName" name="OutCustomerName" value="@Model.Transfer.OutCustomerName" style="width: 173px; height: 30px;" readonly="readonly">
        </div>
        <div class="fitem1">
            <label>
                合同编号:
            </label>
            <input class="easyui-textbox" id="ContractNo" name="ContractNo" value="@Model.Transfer.ContractNo" style="width: 173px; height: 30px;" readonly="readonly">
            <label>
                租仓类型:
            </label>
            <input id="RentalWarehouseType" value="@Model.Transfer.RentalWarehouseType" class="easyui-numberbox" data-options="prompt:'租仓类型(1:零仓,2:包仓)'" style="width: 173px; height: 30px;" />
            <label>
                冷藏算法:
            </label>
            <input id="ColdAlgorithm" value="@Model.Transfer.ColdAlgorithm" class="easyui-numberbox" data-options="prompt:'冷藏算法'" style="width: 173px; height: 30px;" />
            <label>
                计费单位:
            </label>
            <input id="ChargingUnit" value="@Model.Transfer.ChargingUnit" class="easyui-numberbox" data-options="prompt:'计费单位'" style="width: 173px; height: 30px;" />
            <label>
                按吨操作:
            </label>
            <input class="easyui-switchbutton" id="sbIsByTon" value="@Model.Transfer.IsByTon" data-options="onText:'是',offText:'否'">
        </div>
        <div class="fitem1">
            <label>
                周期:
            </label>
            <input id="Cycle" value="@Model.Transfer.Cycle" class="easyui-numberbox" data-options="prompt:'周期'" style="width: 173px; height: 30px;" />
            <label>
                冷藏单价:
            </label>
            <input id="ColdUnitPrice" name="ColdUnitPrice" value="@Model.Transfer.ColdUnitPrice" class="easyui-numberbox" data-options="precision:'2',prompt:'冷藏单价'" style="width: 173px; height: 30px;" readonly="readonly" />
            <label>
                不足n吨算n吨:
            </label>
            <input id="Tonnage" value="@Model.Transfer.Tonnage" class="easyui-numberbox" data-options="prompt:'不足n吨算n吨'" style="width: 173px; height: 30px;" />
            <label>
                当天冷藏费:
            </label>
            @*<input class="easyui-textbox" id="CurrentDayColdCost" name="CurrentDayColdCost" style="width: 173px; height: 30px;" readonly="readonly">*@
            <input class="easyui-checkbox" id="CurrentDayColdCost1" name="CurrentDayColdCost1"><label>计入转出客户</label>
            <input class="easyui-checkbox" id="CurrentDayColdCost2" name="CurrentDayColdCost2"><label>计入转入客户</label>
        </div>
        <div class="fitem1">
            <label>
                总吨重:
            </label>
            <input id="TotalTon" name="TotalTon" value="@Model.Transfer.TotalTon" class="easyui-numberbox" data-options="precision:'4',prompt:'总吨重'" style="width: 173px; height: 30px;" readonly="readonly" />
            <label>
                总件数:
            </label>
            <input id="Total" value="@Model.Transfer.Total" class="easyui-numberbox" data-options="prompt:'总件数'" style="width: 173px; height: 30px;" />
            <label>
                转入金额:
            </label>
            <input id="InAmount" name="InAmount" value="@Model.Transfer.InAmount" class="easyui-numberbox" data-options="precision:'2',prompt:'转入金额'" style="width: 173px; height: 30px;" readonly="readonly" />
            <label>
                转出金额:
            </label>
            <input id="OutAmout" name="OutAmout" value="@Model.Transfer.OutAmout" class="easyui-numberbox" data-options="precision:'2',prompt:'转出金额'" style="width: 173px; height: 30px;" readonly="readonly" />

        </div>
        <div class="fitem1">
            <label>
                图片:
            </label>
            <input type="hidden" id="hidFileId" />
            <input id="filebox" class="easyui-filebox" name="file" data-options="buttonText:'选择文件',accept:'image/*',onChange:fileChange" /><a href="@Model.FilePath" target="_blank">@Model.FileName</a>
        </div>
        <div class="fitem1">
            <label>
                备注:
            </label>
            <textarea rows="4" cols="4" style="width: 400px; height: 90px; vertical-align: top" name="Remark" id="Remark" autocomplete="off" placeholder="200字以内">@Model.Transfer.Remark</textarea>
        </div>
        <div id="Wl">
            <div id="tabs" class="easyui-tabs" fit="true" border="false" style="width:500px;height:300px; padding-top:5px;">
                <div title="商品明细">
                    <input id="DomNum" type="hidden" value="@(Model.Details.Count+1)" />
                    @{
                        int i = 1;
                    }
                    <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addDom()">添加</a>
                    <table class="gridtable" id="detailgird">
                        <thead>
                            <tr>
                                <th>原商品批号</th>
                                <th>新商品批号</th>
                                <th>商品名称</th>
                                <th>规格</th>
                                <th>件重</th>
                                <th>转卡件数</th>
                                <th>托盘数/面积</th>
                                <th>转卡吨重</th>
                                <th>板位</th>
                                <th>库存件数</th>
                                <th>库存托盘数/面积</th>
                                <th>库存吨重</th>
                                <th>转出仓位</th>
                                <th>转入仓位</th>
                                <th>操作</th>
                            </tr>
                            @foreach (var item in Model.Details)
                            {
                                <tr id="@i">
                                    <td>
                                        <input class="easyui-textbox" id="@("GoodsNo")@i" name="@("GoodsNo")@i" value="@item.GoodsNo" style="width: 173px; height: 30px;" readonly="readonly">
                                        <input type="hidden" id="@("DetailDomId")@i" value="@i" />
                                        <input type="hidden" id="@("DetailId")@i" value="@item.Id" />
                                        <input type="hidden" id="@("TransferId")@i" value="@item.TransferId" />
                                    </td>
                                    <td>
                                        <input class="easyui-textbox" id="@("NewGoodsNo")@i" name="@("NewGoodsNo")@i" value="@item.NewGoodsNo" style="width: 173px; height: 30px;" readonly="readonly">
                                    </td>
                                    <td>
                                        <input class="easyui-textbox" id="@("GoodsName")@i" name="@("GoodsName")@i" value="@item.GoodsName" style="width: 173px; height: 30px;" readonly="readonly">
                                        <input type="hidden" id="@("GoodsId")@i" value="@item.GoodsId" />
                                    </td>
                                    <td>
                                        <input class="easyui-textbox" id="@("GoodsSpecName")@i" name="@("GoodsSpecName")@i" value="@item.GoodsSpecName" style="width: 173px; height: 30px;" readonly="readonly">
                                        <input type="hidden" id="@("GoodsSpecId")@i" value="@item.GoodsSpecId" />
                                    </td>
                                    <td><input id="@("Weight")@i" name="@("Weight")@i" value="@item.Weight" class="easyui-numberbox" data-options="precision:'4',prompt:'件重'" style="width: 173px; height: 30px;" readonly="readonly" /></td>
                                    <td><input id="@("TransferNumber")@i" name="@("TransferNumber")@i" value="@item.TransferNumber" class="easyui-numberbox" data-options="prompt:'数量',onChange:calculateWeight" style="width: 173px; height: 30px;" /></td>
                                    <td><input id="@("Area")@i" name="@("Area")@i" value="@item.Area" class="easyui-numberbox" data-options="precision:'2',prompt:'面积'" style="width: 173px; height: 30px;" /></td>
                                    <td><input id="@("TonWeight")@i" name="@("TonWeight")@i" value="@item.TonWeight" class="easyui-numberbox" data-options="precision:'4',prompt:'吨重',onChange:calculateWeight" style="width: 173px; height: 30px;" /></td>
                                    <td><input id="@("PlatePosition")@i" class="easyui-numberbox" value="@item.PlatePosition" data-options="prompt:'板数'" style="width: 173px; height: 30px;" /></td>
                                    <td><input id="@("InventoryNumber")@i" class="easyui-numberbox" value="@item.InventoryNumber" data-options="prompt:'货存件数'" style="width: 173px; height: 30px;" readonly="readonly" /></td>
                                    <td><input id="@("InventoryArea")@i" class="easyui-numberbox" value="@item.InventoryArea" data-options="precision:'2',prompt:'库存托盘数/面积'" style="width: 80px; height: 30px;" readonly="readonly" /></td>
                                    <td><input id="@("InventoryTonWeight")@i" class="easyui-numberbox" value="@item.InventoryTonWeight" data-options="precision:'4',prompt:'库存吨重'" style="width: 80px; height: 30px;" readonly="readonly" /></td>
                                    <td>
                                        <input class="easyui-textbox" id="@("OutHouseName")@i" name="@("OutHouseName")@i" value="@item.OutHouseName" data-options="prompt:'转出仓位'" style="width: 173px; height: 30px;" readonly="readonly">
                                        <input type="hidden" id="@("OutHouse")@i" value="@item.OutHouse" />
                                    </td>
                                    <td><input id="@("InHouse")@i" class="easyui-combobox" value="@item.InHouse" data-options="prompt:'转入仓位'" style="width: 173px; height: 30px;" /></td>
                                    <td><a href="javascript:" class="easyui-linkbutton" iconcls="icon-no" plain="true" style=" width:80px;" onclick="delDom(@i)">删除</a></td>
                                </tr>
                                i++;
                            }
                        </thead>
                    </table>
                    @{
                        i = 1;
                    }
                    @foreach (var item in Model.Details)
                    {
                        <script type="text/javascript">
$(function () {
                            InitInWareHouse(@i);
});
                        </script>
                        i++;
                    }
                </div>
                <div title="转出客户其他费用">
                    <input id="CostDomNum" type="hidden" value="@(Model.OutCosts.Count+1)" />
                    @{
                        int oi = 1;
                    }
                    <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addDom3()">添加</a>
                    <table class="gridtable" id="outcostgird">
                        <thead>
                            <tr>
                                <th>费用类型</th>
                                <th>杂费单价</th>
                                <th>单位</th>
                                <th>计算数量</th>
                                <th>金额</th>
                                <th>操作</th>
                            </tr>
                            @foreach (var item in Model.OutCosts)
                            {
                                <tr id="@("OutCostTr")@oi">
                                    <td>
                                        <input id="@("OCostType")@oi" class="easyui-combobox" value="@item.CostId" data-options="prompt:'费用类型',onChange:calculateAmount2" style="width: 173px; height: 30px;" />
                                        <input type="hidden" id="@("OCostTypeId")@oi" value="@item.CostId" />
                                        <input type="hidden" id="@("OCostDomId")@oi" value="@oi" />
                                        <input type="hidden" id="@("OCostsId")@oi" value="@item.Id" />
                                        <input type="hidden" id="@("OTransferId")@oi" value="@item.TransferId" />
                                    </td>
                                    <td><input id="@("OUnitPrice")@oi" name="@("UnitPrice")@oi" value="@item.UnitPrice" class="easyui-numberbox" data-options="precision:'2',prompt:'杂费单价',onChange:calculateAmount2" style="width: 173px; height: 30px;" /></td>
                                    <td><input id="@("OChargingUnit")@oi" class="easyui-combobox" value="@item.Unit" data-options="prompt:'单位'" style="width: 173px; height: 30px;" /></td>
                                    <td><input id="@("ONumber")@oi" class="easyui-numberbox" value="@item.Number" data-options="prompt:'计算数量',onChange:calculateAmount2" style="width: 173px; height: 30px;" /></td>
                                    <td><input id="@("OAmount")@oi" name="@("Amount")@oi" value="@item.Amount" class="easyui-numberbox" data-options="precision:'2',prompt:'金额'" style="width: 173px; height: 30px;" /></td>
                                    <td><a href="javascript:" class="easyui-linkbutton" iconcls="icon-no" plain="true" style=" width:80px;" onclick="delDom3(@oi)">删除</a></td>
                                </tr>
                                oi++;
                            }
                        </thead>
                    </table>
                    @{
                        oi = 1;
                    }
                    @foreach (var item in Model.OutCosts)
                    {
                        <script type="text/javascript">
$(function () {
    InitCostTypesCombogridById("OCostType"+@oi);
    InitChargingUnitComboboxById("OChargingUnit" +@oi);
});
                        </script>
                        oi++;
                    }
                </div>
                <div title="转入客户其他费用">
                    <input id="CostDomNum" type="hidden" value="@(Model.InCosts.Count+1)" />
                    @{
                        int ci = 1;
                    }
                    <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addDom2()">添加</a>
                    <table class="gridtable" id="costgird">
                        <thead>
                            <tr>
                                <th>费用类型</th>
                                <th>杂费单价</th>
                                <th>单位</th>
                                <th>计算数量</th>
                                <th>金额</th>
                                <th>操作</th>
                            </tr>
                            @foreach (var item in Model.InCosts)
                            {
                                <tr id="@("CostTr")@ci">
                                    <td>
                                        <input id="@("CostType")@ci" class="easyui-combobox" value="@item.CostId" data-options="prompt:'费用类型',onChange:calculateAmount" style="width: 173px; height: 30px;" />
                                        <input type="hidden" id="@("CostTypeId")@ci" value="@item.CostId" />
                                        <input type="hidden" id="@("CostDomId")@ci" value="@ci" />
                                        <input type="hidden" id="@("CostsId")@ci" value="@item.Id" />
                                        <input type="hidden" id="@("ITransferId")@ci" value="@item.TransferId" />
                                    </td>
                                    <td><input id="@("UnitPrice")@ci" name="@("UnitPrice")@ci" value="@item.UnitPrice" class="easyui-numberbox" data-options="precision:'2',prompt:'杂费单价',onChange:calculateAmount" style="width: 173px; height: 30px;" /></td>
                                    <td><input id="@("ChargingUnit")@ci" class="easyui-combobox" value="@item.Unit" data-options="prompt:'单位'" style="width: 173px; height: 30px;" /></td>
                                    <td><input id="@("CNumber")@ci" class="easyui-numberbox" value="@item.Number" data-options="prompt:'计算数量',onChange:calculateAmount" style="width: 173px; height: 30px;" /></td>
                                    <td><input id="@("Amount")@ci" name="@("Amount")@ci" value="@item.Amount" class="easyui-numberbox" data-options="precision:'2',prompt:'金额'" style="width: 173px; height: 30px;" /></td>
                                    <td><a href="javascript:" class="easyui-linkbutton" iconcls="icon-no" plain="true" style=" width:80px;" onclick="delDom2(@ci)">删除</a></td>
                                </tr>
                                ci++;
                            }
                        </thead>
                    </table>
                    @{
                        ci = 1;
                    }
                    @foreach (var item in Model.InCosts)
                    {
                        <script type="text/javascript">
$(function () {
    InitCostTypesCombogrid2(@ci);
    InitChargingUnitCombobox(@ci);
});
                        </script>
                        ci++;
                    }
                </div>
            </div>
        </div>
        <div class="fitem1">
            @{
                var modifyuser = Model.Transfer.ModifyUserId == 0 ? Gx.Dal.Shared.UserContext.CurrentUser.EmpName : Model.Transfer.ModifyUser;
                var modifytime = Model.Transfer.ModifyTime.ToString("yyyy-MM-dd") == "1911-01-01" ? "" : Model.Transfer.ModifyTime.ToString("yyyy-MM-dd");
            }
            <label>
                制单人:
            </label>
            <label>
                @Model.Transfer.CreateUser
            </label>

            <label>
                制单日期:
            </label>
            <label>
                @Model.Transfer.CreateTime.ToString("yyyy-MM-dd")
            </label>
            <label>
                修改人:
            </label>
            <label>
                @modifyuser
            </label>
            <label>
                修改日期:
            </label>
            <label>
                @modifytime
            </label>
        </div>
    </form>
    <div id="incustomerselecttoolbar">
        <input id="SelectCustomerText1" class="easyui-textbox " style="width: 173px; height: 30px;" />
        <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-search" onclick="querycustomer1()">查询</a>
    </div>
    <div id="outcustomerselecttoolbar">
        <input id="SelectCustomerText2" class="easyui-textbox " style="width: 173px; height: 30px;" />
        <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-search" onclick="querycustomer2()">查询</a>
    </div>
</div>

<div id="dlg" class="easyui-dialog" title="商品引导转卡" data-options="iconCls:'icon-save'"
     closed="true" style="width: 1050px; height: auto; padding: 10px 20px" buttons="#dlg-buttons" modal="true">
    <table id="dg" class="easyui-datagrid" style=": $(this).width() * 0.2; height: auto;"
           url="/GoodsOrder/GetLKWarehouseEntryDetailsByCustomerId" toolbar="#tb" rownumbers="true" pagination="true"
           pagelist="[15]" fitcolumns="true" singleselect="true">
        <thead>
            <tr>
                <th field="GoodsNo" align="right" width="10%">
                    商品批号
                </th>
                <th field="GoodsId" align="right" width="10%" hidden="hidden">
                    商品id
                </th>
                <th field="GoodsSpecId" align="right" width="10%" hidden="hidden">
                    规格
                </th>
                <th field="WareHouseId" align="right" width="10%" hidden="hidden">
                    仓位
                </th>
                <th field="GoodsName" align="right" width="10%">
                    商品名称
                </th>
                <th field="GoodsSpecName" align="right" width="10%">
                    规格名称
                </th>
                <th field="WareHouseName" align="right" width="10%">
                    仓库名称
                </th>
                <th field="Weight" align="right" width="10%">
                    件重
                </th>
                <th field="Number" align="right" width="10%">
                    件数
                </th>
                <th field="Area" align="right" width="10%">
                    面积
                </th>
                <th field="AvNumber" align="right" width="10%">
                    每板件数
                </th>
                <th field="TonWeight" align="right" width="10%">
                    吨重
                </th>
                <th field="PlateNumber" align="right" width="10%">
                    板数
                </th>
                <th field="ProductionDate" align="right" width="10%">
                    生产日期
                </th>
                <th field="ExpirationDate" align="right" width="10%">
                    保质日期
                </th>
                <th field="ProducingArea" align="right" width="10%">
                    产地
                </th>
                <th field="Remark" align="right" width="10%">
                    备注
                </th>
            </tr>
        </thead>
    </table>
</div>
<div id="dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="selectEntryDetail()">选择</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
</div>











